package com.tbit.uqbike.service.business.impl;

import com.tbit.uqbike.object.pojo.Eventdetail;
import com.tbit.uqbike.service.business.EventdetailService;
import com.tbit.uqbike.webmanager.dao.core.EventdetailDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 活动详细(Eventdetail)表服务实现类
 *
 * @author jing
 * @since 2020-12-30 18:49:12
 */
@Service("eventdetailService")
public class EventdetailServiceImpl implements EventdetailService {
    @Resource
    private EventdetailDao eventdetailDao;

    /**
     * 通过ID查询单条数据
     *
     * @param detailId 主键
     * @return 实例对象
     */
    @Override
    public Eventdetail queryById(Integer detailId) {
        return this.eventdetailDao.queryById(detailId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Eventdetail> queryAllByLimit(int offset, int limit) {
        return this.eventdetailDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param eventdetail 实例对象
     * @return 实例对象
     */
    @Override
    public Eventdetail insert(Eventdetail eventdetail) {
        this.eventdetailDao.insert(eventdetail);
        return eventdetail;
    }

    /**
     * 修改数据
     *
     * @param eventdetail 实例对象
     * @return 实例对象
     */
    @Override
    public Eventdetail update(Eventdetail eventdetail) {
        this.eventdetailDao.update(eventdetail);
        return this.queryById(eventdetail.getDetailId());
    }

    /**
     * 通过主键删除数据
     *
     * @param detailId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer detailId) {
        return this.eventdetailDao.deleteById(detailId) > 0;
    }
}